#include "GamePiece.h"
#include "../Wrapper/CSGD_TextureManager.h"

GamePiece::GamePiece() : pieceType(NULL), texManager(NULL)
{
}

GamePiece::GamePiece(PIECE_TYPE _type, bool _playStatus)
{
	texManager = CSGD_TextureManager::GetInstance();
	pieceType = _type;
	inPlay = _playStatus;
	
	// BaseObject variables
	SetWidth(IMAGE_SIZE);
	SetHeight(IMAGE_SIZE);

	switch (pieceType)
	{
	case PIECE_TRACK_STRAIGHT:
		{
			SetPositionX(150.0f);
			SetPositionY(550.0f);
			SetImageID(texManager->LoadTexture("Resource/Graphics/HUD/piece_track_straight.png", D3DCOLOR_XRGB(255, 0, 255)));
		}
		break;

	case PIECE_TRACK_CURVE:
		{
			SetPositionX(350.0f);
			SetPositionY(550.0f);
			SetImageID(texManager->LoadTexture("Resource/Graphics/HUD/piece_track_curve.png"));
		}
		break;

	case PIECE_BOMB:
		{
			SetPositionX(550.0f);
			SetPositionY(550.0f);
			SetImageID(texManager->LoadTexture("Resource/Graphics/HUD/piece_bomb.png"));
		}
		break;
	};
}

GamePiece::~GamePiece()
{
}

void GamePiece::Update(float _dT)
{
}

void GamePiece::Render()
{
	texManager->Draw(GetImageID(), GetPositionX(), GetPositionY(), 1.0f, 1.0f, NULL, GetWidth() * 0.5f, GetHeight() * 0.5f, D3DXToRadian(GetRotation()));
}

RECT GamePiece::GetCollisionRect()
{
	RECT collisionRect = {(LONG)GetPositionX(), 
						  (LONG)GetPositionY(), 
						  (LONG)(GetPositionX() + GetWidth()), 
						  (LONG)(GetPositionY() + GetHeight())};

	return collisionRect;
}

bool GamePiece::CheckCollision(BaseInterface* _base)
{

	return false;
}